Skip to content

fix: add focus state to swaps input for improved accessibility #29252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 17, 2024

Conversation

georgewrmarshall
Copy link
Contributor

@georgewrmarshall georgewrmarshall commented Dec 16, 2024

Description

The current swaps input implementation hides the focus indicator, making it inaccessible for users with vision impairments and those relying on keyboard navigation. This creates barriers for:

  • Users with low vision who need clear visual indicators
  • Users with motor impairments who navigate via keyboard
  • Users of screen magnification tools who need to track their position

This PR improves accessibility by:

  1. Removing 'outline: none' from the swaps input to restore focus visibility
  2. Adjusting padding (from 0 to 4px) and margins to maintain visual consistency
  3. Adding proper focus visibility for keyboard navigation

These changes ensure compliance with WCAG 2.1 Success Criterion 2.4.7 (Focus Visible), which requires that keyboard focus indicators be visible and distinguishable.

Related issues

Fixes: #26662

Manual testing steps

  1. Navigate to the swaps page
  2. Use Tab key to move focus to the input field
  3. Verify that a visible focus indicator appears around the input
  4. Ensure the text alignment and spacing remain consistent
  5. Test that the input remains right-aligned with the new padding

Screenshots/Recordings

Before

Input field shows no focus indicator when navigating with keyboard

before.mov

After

Input field shows clear focus indicator when navigating with keyboard, with padding-right: 4px

after720.mov

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed)
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots

@georgewrmarshall georgewrmarshall requested a review from a team as a code owner December 16, 2024 22:05
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbot metamaskbot added the team-design-system All issues relating to design system in Extension label Dec 16, 2024
@georgewrmarshall georgewrmarshall changed the title Add focus state to swaps input for improved accessibility fix: add focus state to swaps input for improved accessibility Dec 16, 2024
@georgewrmarshall georgewrmarshall force-pushed the fix/accessibility-bug-swaps-input-focus branch from 61b2152 to 43eed26 Compare December 16, 2024 22:17
@@ -893,6 +893,7 @@ export default function PrepareSwapPage({
display={DISPLAY.FLEX}
justifyContent={JustifyContent.spaceBetween}
alignItems={AlignItems.center}
gap={4}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds gap between asset selector and input

Screenshot 2024-12-17 at 8 49 40 AM

Comment on lines -136 to +139
outline: none;
margin-right: -4px;

input {
padding-right: 0;
padding-right: 4px;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Negative margin allows for alignment and padding of number to remain the same while input is in focus state

@metamaskbot
Copy link
Collaborator

Builds ready [43eed26]
Page Load Metrics (2047 ± 150 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint169428202063319153
domContentLoaded163927542023310149
load169527762047312150
domInteractive28124472311
backgroundConnect88822178
firstReactRender1783432512
getState671282010
initialActions01000
loadScripts120621381530251121
setupStore65415136
uiStartup190731412333362174
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 6 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@DDDDDanica
Copy link
Contributor

Tested:
✅ access to input in swaps with tabs
✅ input a value in that input with keyboard

@DDDDDanica DDDDDanica added this pull request to the merge queue Dec 17, 2024
Merged via the queue into main with commit fe80943 Dec 17, 2024
77 checks passed
@DDDDDanica DDDDDanica deleted the fix/accessibility-bug-swaps-input-focus branch December 17, 2024 17:13
@github-actions github-actions bot locked and limited conversation to collaborators Dec 17, 2024
@metamaskbot metamaskbot added the release-12.11.0 Issue or pull request that will be included in release 12.11.0 label Dec 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.11.0 Issue or pull request that will be included in release 12.11.0 team-design-system All issues relating to design system in Extension
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[Bug]: (Accessibility) Swaps Input Field Lacks Focus State Outline
4 participants